﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SpeakTechnology.AccessToDates;
namespace SpeakTechnology.LogicOfBussiness
{
    class C_usuario
    {
        public bool valir_name_pass(string name, string password)
        {
            if ((name == "") || (password == ""))
            {
                return true;
            }
            return false;
        }
        public static bool ver_name(string name) 
        {
            BodegaEntities1 db = new BodegaEntities1();
            return db.Usuario.Any(u => u.usuario1 == name);
        }
        public static bool usuario(string name, string password)
        {
            BodegaEntities1 db = new BodegaEntities1();
            int pass = Convert.ToInt32(password);
            return db.Usuario.Any(u => u.usuario1 == name && u.password == pass);
        }
        public bool save_user(string name, string last, string user, string password) 
        {
            if (ver_name(user) == true)
            {
                return false;
            }
            else
            {
                BodegaEntities1 db = new BodegaEntities1();
                int pass = Convert.ToInt32(password);
                Usuario usa = new Usuario 
                {
                    Nombre=name,
                    Apellido_paterno=last,
                    usuario1=user,
                    password=pass
                };
                db.Usuario.Add(usa);
                db.SaveChanges();
            }
            return true;
        }
        public bool validar_name_last_user_pass(string name, string last, string user, string pass) 
        {
            if((name=="")||(last=="")||(user=="")||(pass==""))
            {
                return true;
            }
            return false;
        }
    }
}
